<template>
  <div class="login-container flx-center">
    <div class="login-box">
      <SwitchDark class="dark" />
      <div class="login-left">
        <img class="login-left-img" src="@/assets/images/login_left.png" alt="login" />
      </div>
      <div class="login-form">
        <div class="login-logo">
          <img v-show="!isRegistration" class="login-icon" src="@/assets/images/logo.svg" alt="" />
          <h2 class="logo-text">{{ isRegistration ? "用户注册" : title }}</h2>
        </div>
        <div v-if="!isRegistration"><LoginForm :mobile="mobile" /></div>
        <div v-else><RegistrationForm /></div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts" name="login">
import { ref, onUnmounted } from "vue";
import LoginForm from "./components/LoginForm.vue";
import RegistrationForm from "./components/RegistrationForm.vue";
import SwitchDark from "@/components/SwitchDark/index.vue";
import mittBus from "@/utils/mittBus";
const title = import.meta.env.VITE_GLOB_APP_TITLE;

// 变量
let isRegistration = ref(false);
let mobile = ref("");

mittBus.on("handoff", (val: boolean) => {
  isRegistration.value = val;
});
mittBus.on("iphone", data => {
  mobile.value = data;
});
onUnmounted(() => {
  mittBus.off("handoff");
  mittBus.off("iphone");
});
</script>

<style scoped lang="scss">
@import "./index.scss";
</style>
